/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ar.com.gestion.tests;

import java.awt.FlowLayout;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeListener;
import javax.swing.Action;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

/**
 *
 * @author martinLequerica
 */
public class NuevoTest extends JFrame{
    
    public NuevoTest(){
        
        JList lista = new JList();
        
        JPanel jp = new JPanel();
        jp.setLayout(new FlowLayout());
        jp.add(lista);
        add(jp);
        
        setSize(500, 500);
        setVisible(true);
        
        
        
        DefaultListModel dlm = new DefaultListModel();
        dlm.addElement("uno");
        dlm.addElement("dos");
        dlm.addElement("tres");
        dlm.addElement("cuatro");
        lista.setModel(dlm);
        int si = lista.getSelectedIndex();
        
        JOptionPane.showMessageDialog(null, si);
        JButton boton = new JButton();
        
        boton.addActionListener(new Action() {

            @Override
            public Object getValue(String string) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            @Override
            public void putValue(String string, Object o) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            @Override
            public void setEnabled(boolean bln) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            @Override
            public boolean isEnabled() {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            @Override
            public void addPropertyChangeListener(PropertyChangeListener pl) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            @Override
            public void removePropertyChangeListener(PropertyChangeListener pl) {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            @Override
            public void actionPerformed(ActionEvent ae) {
          
                JOptionPane.showMessageDialog(null, "nose");
                
            }
        });
        
        jp.add(boton);
        
        JButton otro = new JButton("nose");
        otro.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                JOptionPane.showMessageDialog(null, "action");
            }
        });
        jp.add(otro);
        
    }
    
}
